<?php

/*
	[ English learning assistant system]
	NAME:admin_model
*/
if (!defined('IN_ELS'))
{
    die('Hacking attempt');
}

class adminbase extends base {
	function adminbase() {
		$this->base();
	}
	
	function getLoginInfo($userName){
		$sqlText = "select *,FROM_UNIXTIME(regdate) regdate,FROM_UNIXTIME(lastlogintime) lastlogintime 
					from admins where username='".$userName."' ";
		$retData = $this->db->fetch_first($sqlText);
		return $retData;
	}
	
	function getUserInfo($uid) {
		$sqlText = "select * from admins where uid=$uid";
		$retData = $this->db->fetch_first($sqlText);
		return $retData;
	}
	
	function upAdminMember($data,$where){
		$retValue = $this->dbUpdate("admins",$data,$where);
		return $retValue;
	}
	//获取首页图片轮换内容
	function getrotateContent($rotateid){
		$sqlText = "select * from rotate where rotateid = '$rotateid'";
		$data=$this->db->fetch_first($sqlText);
		return $data;
	}
	
	function uprotate($data,$where){
		$retValue = $this->dbUpdate("rotate",$data,$where);
		return $retValue;
	}
	function insertrotate($data){
		$retValue = $this->dbInsert("rotate",$data);
		return $retValue;
	}
	function getrotateCount($where){
		$sqlText = "select count(*) from rotate ";
		$sqlText .= $where;
		$data=$this->db->result_first($sqlText);
		return $data;
	}
	function getrotateList($where,$limitText){
		$sqlText  = "select *,FROM_UNIXTIME(create_time,'%Y-%m-%d %H:%i') create_time from rotate ";
		$sqlText .= $where;
		$sqlText .= " order by create_time desc ";
		$sqlText .= $limitText;
		$data=$this->db->fetch_all($sqlText);
		return $data;
	}
	function getfoodCount($where){
		$sqlText = "select count(*) from food ";
		$sqlText .= $where;
		$data=$this->db->result_first($sqlText);
		return $data;
	}
	function getfood_shopCount($where){
		$sqlText = "select count(*) from food_shop ";
		$sqlText .= $where;
		$data=$this->db->result_first($sqlText);
		return $data;
	}
	function getfoodList($where,$limitText){
		$sqlText  = "select *,FROM_UNIXTIME(create_time,'%Y-%m-%d') create_time from food ";
		$sqlText .= $where;
		$sqlText .= " order by create_time desc ";
		$sqlText .= $limitText;
		$data=$this->db->fetch_all($sqlText);
		return $data;
	}
	function getfood_shopList($where,$limitText){
		$sqlText  = "select *,FROM_UNIXTIME(create_time,'%Y-%m-%d') create_time from food_shop ";
		$sqlText .= $where;
		$sqlText .= " order by create_time desc ";
		$sqlText .= $limitText;
		$data=$this->db->fetch_all($sqlText);
		return $data;
	}
	function getfood_shopContent($id){
		$sqlText = "select shopid,score from food_shop where shopid=".$id;
		$data=$this->db->fetch_first($sqlText);
		return $data;
	}
	function getfoodContent($id){
		$sqlText = "select foodid,score from food where foodid=".$id;
		$data=$this->db->fetch_first($sqlText);
		return $data;
	}
	function insertmembers($data){
		$retValue = $this->dbInsert("members",$data);
		return $retValue;
	}
	function getmembersContent($mobile_phone){
		$sqlText = "select mobile_phone from members where mobile_phone=".$mobile_phone;
		$data=$this->db->fetch_first($sqlText);
		return $data;
	}
	function getHuodong_a_excel($where){
		$sqlText = "select * from booth ";
		$sqlText .= $where;
		$sqlText .= " order by prize_time desc ";
		$data=$this->db->fetch_all($sqlText);
		return $data;
	}
	function getHuodong_b_excel($where){
		$sqlText = "select * from huodong ";
		$sqlText .= $where;
		$sqlText .= " order by prize_time desc ";
		$data=$this->db->fetch_all($sqlText);
		return $data;
	}
	function getmembersContents($mid){
		$sqlText = "select * from members where mid=".$mid;
		$data=$this->db->fetch_first($sqlText);
		return $data;
	}
	//每日短信信息
	function insertsms($data){
		$retValue = $this->dbInsert("sms",$data);
		return $retValue;
	}
	//导入信息查询登录名
	function getnickname($phone){
		$sqlText = "select * from members where mobile_phone=".$phone; 
		$data=$this->db->fetch_first($sqlText);
		return $data;
	}
	//导入数据放重复
	function getoldsms($where){
		$sqlText = "select * from sms "; 
		$sqlText .= $where;
		$data=$this->db->fetch_first($sqlText);
		return $data;
	}
	
	
}

?>